#ifndef _DICOM_UPLOAD_SAME_HASH_CHECKER_
#define _DICOM_UPLOAD_SAME_HASH_CHECKER_

#include "dicom/gateway.h"
#include "dicom/dicom_conf.h"
#include "dicom/storage/local_cache.h"
#include "dicom/upload/hash_cache.h"
#include <surbasic/AccessToken.h>
#include <surbasic/SDCurl.h>
#include <surbasic/DateObjects.h>

namespace dicom {

using SDBasic::token::AccessToken;

struct ServerHashEntry {
  int64_t src_size;
  std::string hexkey;
  std::string enc_digest;
  int64_t enc_size;
};

typedef std::vector<ServerHashEntry> ServerHashEntryList;

class SameHashChecker {
 public:
  SameHashChecker(HashCache* hcache);
  ~SameHashChecker();

  Status GetServerHashEntryListFromServer(uint64_t surdoc_key,
                                          const std::string& digest,
                                          const std::string& sha512,
                                          ServerHashEntryList* list);

  bool CanRapidUploadFastCheck(const ServerHashEntryList* list,
                               const std::string& src_md5, HashEntry* hash);

  bool CanRapidUploadSlowCheck(const ServerHashEntryList* list,
                               const std::string& src_file, HashEntry* hash);

 private:
  HashCache* hcache_;
};
}

#endif  // _DICOM_UPLOAD_SAME_HASH_CHECKER_
